package com.project.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.project.bean.RecordBean;
import com.project.mapper.IRecordMapper;
import com.project.service.IRecordService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.time.LocalDate;

@Service
@Transactional
public class IRecordServiceImpl implements IRecordService {
    @Autowired
    private IRecordMapper recordMapper;

    @Override
    public IPage<RecordBean> findByItem(Integer pageNO, LocalDate startDate, LocalDate endDate) {
        QueryWrapper<RecordBean> qw = new QueryWrapper<>();
        if (startDate != null) {
            qw.ge("r_loginDate", startDate);
        }
        if (endDate != null) {
            qw.le("r_loginDate", endDate);
        }
        return recordMapper.selectPage(new Page<>(pageNO, 3), qw);
    }
}
